<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">商品优惠</span>
      <span @click="showBeautyBox = true">组件美化</span>
    </div>
    <div class="control-body">
      <div class="control-section">
        <hideModuleControl
          :isHide.sync="params.params.showGoodsDiscount"
          title="商品优惠"
          @reset="reset('showGoodsDiscount')"
          @hideChange="setShowGoodsDiscount"
        ></hideModuleControl>
      </div>
    </div>

    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 背景 -->
        <bgControl
          :backgroudData="params.moduleCss"
          sizeText="750*不限"
        ></bgControl>
        <!-- 间距圆角控制 -->
        <spaceControl
          :spaceData.sync="params.moduleCss"
          @resetSpace="resetSpace"
          @resetMp="resetMp"
        ></spaceControl>
      </div>
    </comBeautyBox>
  </div>
</template>

<script>
import hideModuleControl from "@/components/DiyNew/diy/baseControl/hideModuleControl/index.vue";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";
import { goodsDiscount } from "@/components/DiyNew/diy/systemPages/goodsDetail/dataConfig/config.js";

export default {
  name: "goodsDiscountControl",
  components: {
    bgControl,
    comBeautyBox,
    hideModuleControl,
    spaceControl,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showBeautyBox: false,
    };
  },
  watch: {},
  computed: {},
  created() {},
  methods: {
    // 重置显示隐藏模块
    reset(key) {
      this.$set(this.params.params, key, goodsDiscount.params[key]);
    },
    setShowGoodsDiscount(e) {
      this.$set(this.params.params, "showGoodsDiscount", e);
    },
    // 重置圆角
    resetSpace(e) {
      let type = e.type;
      console.log(type);
      this.$set(this.params.moduleCss, type, 0);
    },
    // 重置边距
    resetMp() {
      this.$set(this.params.moduleCss, "margin", 0);
      this.$set(this.params.moduleCss, "padding", 0);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
        }
        .flex-between {
          display: flex;
          justify-content: space-between;
          align-items: center;
        }
        .reset {
          font-size: 12px;
          color: #9e9e9e;
          cursor: pointer;
        }
        .control-content {
          .example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 38px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 9px;
            }
            .example-item:last-child {
              margin-right: 0;
            }
          }
        }
        .border-select,
        .fixed-top-select {
          width: 100%;
          height: 100%;
          ::v-deep .ant-select-selection--single {
            height: 100%;
            border: 0 none;
            background: #f2f2f2;
          }
          ::v-deep .ant-select-selection__rendered {
            line-height: 40px;
          }
        }
      }
      .title-section,
      .capsule-section {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          display: flex;
          align-items: center;
          .title-name-input {
            width: 196px;
            height: 40px;
            border-radius: 4px;
            input {
              height: 100%;
              background-color: #f6f7f9;
              border: 0 none;
            }
            input:hover {
              background-color: #f2f2f2;
            }
          }
          .hidden-icon {
            width: 24px;
            height: 24px;
            background: #f6f7f9;
            border-radius: 4px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 16px;
            margin-left: 8px;
            cursor: pointer;
          }
        }
      }

      .capsule-section {
        .control-content {
          width: 100%;
          height: 40px;
          background: #f6f7f9;
          border-radius: 4px;
          .capsule-select {
            width: 100%;
            height: 100%;
            ::v-deep .ant-select-selection--single {
              height: 100%;
              border: 0 none;
              background: #f6f7f9;
            }
            ::v-deep .ant-select-selection--single:hover {
              background: #f2f2f2;
            }
            ::v-deep .ant-select-selection__rendered {
              line-height: 40px;
            }
          }
        }
      }
    }
  }
}
</style>
